package com.shen.accountbook.module.home.booknote;

import android.content.Context;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;

import com.shen.accountbook.R;
import com.shen.accountbook.bean.temp.ThirdSortBean;
import com.shen.accountbook.module.base.BaseHolder;

import java.util.List;

import butterknife.BindView;


public class BookNoteAdapter extends RecyclerView.Adapter<BaseHolder> {

    public BookNoteActivity mContext;
    private LayoutInflater mInflater;
    private List<ThirdSortBean> mBeanList;
    private ItemClickListener mListener;

    public BookNoteAdapter(BookNoteActivity context, List<ThirdSortBean> beanList, ItemClickListener listener) {
        mContext = context;
        mInflater = LayoutInflater.from(context);
        mBeanList = beanList;
        mListener = listener;

    }


    @Override
    public int getItemCount() {
        return (mBeanList == null) ? 0 : mBeanList.size();
    }


    @Override
    public BaseHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        View view = mInflater.inflate(R.layout.item_tb_type, parent, false);
        return new BookNoteHolder(view, mContext, this, mListener);
    }


    @Override
    public void onBindViewHolder(BaseHolder holder, final int position) {
        if (mBeanList == null || mBeanList.size() <= position) {
            return;
        }
        holder.onBindView(mBeanList.get(position), position);
    }

    public void setBeanList(List<ThirdSortBean> beanList) {
        mBeanList = beanList;
    }

    interface ItemClickListener{
        void itemClick(BookNoteAdapter adapter, ThirdSortBean bean);
    }
}
